package com.xy.annotaion.handler.aspect;

import com.xy.annotaion.handler.util.Pointer;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;

/**
 * @author Dell
 */
@Aspect
@Configuration
//只对方法有效，类无效
public class TestLogAspectjConfiguration {

    @Pointcut("@annotation(com.xy.annotaion.handler.annotation.TestLog)")
    public void log(){}

    @Around("log()")
    public Object log(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Pointer.lg("===========start===========");
        Pointer.lg("TestLog aspect method:\t", proceedingJoinPoint);
        Pointer.lg("-->kind:\t", proceedingJoinPoint.getKind());
        Pointer.lg("-->target:\t",proceedingJoinPoint.getTarget());
        Pointer.lg("-->this:\t",proceedingJoinPoint.getThis());
        Pointer.lg("-->args:\t",proceedingJoinPoint.getArgs());
        Pointer.lg("-->staticPart:\t",proceedingJoinPoint.getStaticPart());
        Pointer.lg("-->signature:\t",proceedingJoinPoint.getSignature());
        Pointer.lg("-->sourceLocation:\t",proceedingJoinPoint.getSourceLocation());
        Object obj = proceedingJoinPoint.proceed();
        Pointer.lg("return value:\t",obj);
        Pointer.lg("===========end===========");
        return obj;
    }

}
